package com.ruoyi.psi.purchase.pay.domain;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

/**
 * 采购付款/委外付款表
 * psi_purchase_pay 主
 * @author Drj 2021/6/28
 * 修改：lsy 2021.7.17
 */
public class PurchasePay extends BaseEntity {
    /**
     * 采购付款/委外付款编号
     */
    @NotNull(message = "采购付款不能为空")
    @ApiModelProperty(value = "采购付款", required = true)
    private String purchasePayId;
    /**
     * 供应商编号
     */
    @NotNull(message = "供应商编号不能为空")
    @ApiModelProperty(value = "供应商编号", required = true)
    private String supplierInfoId;
    /**
     * 供应商名称
     */
    @ApiModelProperty("供应商名称")
    private String supplierInfoName;
    /**
     * 付款时间
     */
    @ApiModelProperty(value = "付款时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private java.sql.Timestamp payTime;
    /**
     * 本次付款款总应付金额
     * 采购订单金额总和
     */
    @ApiModelProperty("采购订单金额总和")
    private Double amountPayableTotal;
    /**
     * 本次付款总金额
     */
    @ApiModelProperty("本次付款总金额")
    private Double payTotalAmount;
    /**
     * 本次收款总优惠金额
     * 数据库查询
     */
    @ApiModelProperty("本次收款总优惠金额")
    private Double discountAmount;
    /**
     * 本次付款总实付金额
     */
    @ApiModelProperty("本次付款总实付金额")
    private Double  actualAmountPayTotal;
    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private java.sql.Timestamp createTime;
    /**
     * 备注
     */
    @ApiModelProperty("备注")
    private String remark;

    List<PurchasePayList> purchasePayLists;

    public List<PurchasePayList> getPurchasePayLists() {
        return purchasePayLists;
    }

    public void setPurchasePayLists(List<PurchasePayList> purchasePayLists) {
        BigDecimal bigDecimalPTA = new BigDecimal("0");//payTotalAmount,本次付款总金额
        BigDecimal bigDecimalAAT = new BigDecimal("0");//actualAmountPayTotal,本次付款总实付金额
        BigDecimal bigDecimalAPT = new BigDecimal("0");//amountPayableTotal,本次付款款总应付金额
        for (int i = 0; i < purchasePayLists.size(); i++) {
            bigDecimalPTA = bigDecimalPTA.add(BigDecimal.valueOf(purchasePayLists.get(i).getPayAmount()));//付款金额累加
            bigDecimalAPT = bigDecimalAPT.add(BigDecimal.valueOf(purchasePayLists.get(i).getPurchasePriceTotal()));//订单金额累加
        }
        bigDecimalAAT = bigDecimalPTA.subtract(new BigDecimal(this.discountAmount));//本次付款总实付金额 = 本次付款总金额 - 本次收款总优惠金额
        //存入类中
        setPayTotalAmount(bigDecimalPTA.doubleValue());
        setActualAmountPayTotal(bigDecimalAAT.doubleValue());
        setAmountPayableTotal(bigDecimalAPT.doubleValue());
        this.purchasePayLists = purchasePayLists;
    }
    public String getPurchasePayId() {
        return purchasePayId;
    }

    public void setPurchasePayId(String purchasePayId) {
        this.purchasePayId = purchasePayId;
    }

    public String getSupplierInfoId() {
        return supplierInfoId;
    }

    public void setSupplierInfoId(String supplierInfoId) {
        this.supplierInfoId = supplierInfoId;
    }

    public String getSupplierInfoName() {
        return supplierInfoName;
    }

    public void setSupplierInfoName(String supplierInfoName) {
        this.supplierInfoName = supplierInfoName;
    }

    public Timestamp getPayTime() {
        return payTime;
    }

    public void setPayTime(Timestamp payTime) {
        this.payTime = payTime;
    }

    public Double getAmountPayableTotal() {
        return amountPayableTotal;
    }

    public void setAmountPayableTotal(Double amountPayableTotal) {
        this.amountPayableTotal = amountPayableTotal;
    }

    public Double getPayTotalAmount() {
        return payTotalAmount;
    }

    public void setPayTotalAmount(Double payTotalAmount) {
        this.payTotalAmount = payTotalAmount;
    }

    public Double getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(Double discountAmount) {
        this.discountAmount = discountAmount;
    }

    public Double getActualAmountPayTotal() {
        return actualAmountPayTotal;
    }

    public void setActualAmountPayTotal(Double actualAmountPayTotal) {
        this.actualAmountPayTotal = actualAmountPayTotal;
    }

    @Override
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Override
    public String getRemark() {
        return remark;
    }

    @Override
    public void setRemark(String remark) {
        this.remark = remark;
    }


}
